home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
som.ind
< prev
next >
Wrap
File List
|
1993-08-23
|
9KB
|
460 lines
inst4.1
!****************************************************************
!* *
!* Self Organizing Map *
!* *
!****************************************************************
!
?&In 2
>bge InOK
@Err "Network MUST have at least two input PE's"
:InOK
?SMnr 1
>bge RowOK
@Err "Self Organizing layer MUST have at least 1 row of PE's"
:RowOK
?SMnc 1
>bge ColOK
@Err "Self Organizing layer MUST have at least 1 column of PE's"
:ColOK
?SMmp 0
>beq NotMap1
?&Out 1
>bge OutOK
@Err "Output Layer MUST have at least 1 PE for network map option"
:OutOK
! *** Load the Control Strategy and any fixed schedules ***
@LdCS "sommap" !load mapping control strategy
?BPLf "Delta-Bar-Delta" !DBD?
>bne NotDBD1 !Branch to next test if not
@NLRS "somdbd"
#Incl "somdbd.iif" !special DBD schedule with 0 first col.
=GrLF "somdbd" !instrument list file
>br LdStyle !Continue
:NotDBD1
?BPLf "Ext DBD" !EDBD
>bne NotEDBD1 !Branch if not
@NLRS "somedbd"
#Incl "somedbd.iif" !special EDBD schedule with 0 first col.
=GrLF "somedbd" !instrument list file
>br LdStyle
:NotEDBD1
=GrLF "sombp" !instrument list file
=BBMm 0.4 !Assume momentum of 0.4
>br LdStyle
:NotMap1
=GrLF "som" !instrument list file
@LdCS "somnomap" !Load non-mapping control strategy
:LdStyle
! Load the style sheet
@LdSt "som" !som control strategy
=netn "Untitled"
=DLnF 0 !learn re-display off
=DRcF 0 !recall re-display off
! *** Build the Input Layer ***
@LLdf !load default layer to mi_layer structure
=LDln "In" !layer name
=Lpes &In !copy # of input PEs from menu
=Ltrn "Linear" !buffer
=x 100 !place to put layer on screen
=y 40
@LDfW !Default # weight fields
@LAdd !add the input layer
=n6 LayN !input layer number
! *** Build the 2-D Kohonen Layer ***
@LLdf !start with default layer again
=LDln "2-D Kohonen" !layer name
=Lpes SMnr
*Lpes SMnc !number of PEs
=LDnr SMnr !number of rows
=LInL -0.10 !Init low value
=LInH 0.10 !Init high value
=Lsum "SOM" !SOM summation function
=Llrn "SOM" !SOM learning rule
=Lcmp "SOM" !no output function required
! Build SOM schedule
@NLRS "som"
#Incl "somsched.iif"
=Llrs "som"
+y 40 !up higher on display
#Incl "stdnwgtf.iif" !standard # weight fields
@LAdd
! *** Connect Input Layer to Kohonen Layer ***
=SPEl LayN !2-D Kohonen layer
@SlPE !select it as destination
=NPEl n6 !input layer
@NrPE
=cnwt 0.0 !connection weight
=cnty WVar !variable
=cnsc WAbs !absolute
@LCFl !fully connect to input layer
=n2 Lpes !save for later
=n5 LayN !save for later
=n6 LayN !save for later
! Set up position of any following layers
! Note: this assumes a special style sheet som.nns to
! make it look pretty
=n0 SMnr
*n0 20 !20 pixels for each SOM row
+n0 20
+y n0 !move cursor up higher on display
! coordinate layer?
?SMcd 0
>beq ChkMap
@LLdf !start with default layer again
=LDln "Coords" !layer name
=Lpes 2 !Number of PEs
=Lsum "Sum"
=Llrn 0 !No learn function
=Lcmp "Direct"
=Ltrn "Linear"
=Lerf "standard"
=Llrs "default" !No learning params or noise
@LDfW !Default # weight fields
@LAdd !add the input layer
+y 40
! Coordinate mapping is achieved by special fixed
! connection scheme
! Col coords. -1.0 to 1.0
! f2 increment
?SMnc 2
>blt onecol
=f0 SMnc
-f0 1.0
=f2 2.0
/f2 f0
:onecol
! Row coords. -1.0 to 1.0
! f3 increment
=f1 0.0
?SMnr 2
>blt onerow
=f0 SMnr
-f0 1.0
=f3 2.0
/f3 f0
-f1 1.0
:onerow
=f0 0.0
?SMnc 2
>blt onecol1
-f0 1.0
:onecol1
=n0 1 !first coordinate
=n1 1 !second coordinate
=n2 0 !PE count
=NPEl n5 !SOM layer is source
=SPEl LayN !coordinate layer is dest.
=cnty WFix !fixed weights
=cnsc WRel !Relative
:coordwts
=NPEn n2 !set up source PE
@NrPE
! first coordinate
=SPEn 0
@SlPE
=cnwt f0
@PCon !PE connection
! second coordinates
=SPEn 1
@SlPE
=cnwt f1
@PCon !PE connection
+n2 1 !increment PE count
! Increment column info
+n0 1 !increment x-coord
+f0 f2 !increment col coord.
! Check for end of row
?n0 SMnc !Compare to # cols
>ble coordwts !in mid row, continue
! We are at the end of a row. Reset count and coord.
=n0 1 !reset column counter
=f0 0.0 !reset x coord.
?SMnc 2
>blt onecol2
-f0 1.0 !start at -1.0 unless 1 col
:onecol2
! Increment row info
+f1 f3 !increment row coord
+n1 1 !goto next row
?n1 SMnr !Compare to # rows
>ble coordwts !not at end yet
=n2 Lpes !save for later
=n5 LayN !save for later
=n6 LayN !save for later
=NPEn 0 !set up source PE
=SPEn 0
:ChkMap
?SMmp 0
>beq NotMap2
! Any hidden units?
?&Hd2 1
>blt NoHidden
@LLdf !start with default layer again
=LDln "Hidden" !layer name
=Lpes &Hd2 !Number of PEs
=Lsum "Sum"
=Lcmp "Direct"
=Lerf "standard"
?BPTf "DNNA" !Check for DNNA
>bne DNNA1
=Lsum "DNNA" !DNNA summation
:DNNA1
=Ltrn BPTf !Transfer function
=Llrn BPLf !Learning Rule
!Use net global schedules for DBD and EDBD. Create
!schedules for others
?BPLf "Delta-Bar-Delta" !DBD?
>beq LRS2 !If yes, use net global
?BPLf "Ext DBD" !EDBD
>beq LRS2 !If yes, use net global
=BBLC H2LC !Hidden 2 schedule
@NLRS LDln
#Incl "mapsched.iif" !corrupts n0,n1,f0,f1,f2
=Llrs LDln !Point to it
:LRS2
=f0 n2 !# PEs in previous layer
#Incl "wghtinit.iif"
=LInH f1
=LInL 0.0
-LInL LInH !-ve of high init limit
=n2 Lpes !#processing elements
@LDfW !Default # weight fields
@LAdd
+y 20 !increment for later
! Now hook up previous layer
=cnty WVar !Variable
=cnsc WRel !Relative
=SPEl LayN !Destination layer
@SlPE
=NPEl n6 !Source layer
@NrPE
@LCFl !Full Connections
! Check if Bias desired
?BPBi 0
>ble NoBias1
=NPEl -1
@NrPE
@LCFl !Full Connections
:NoBias1
=n6 LayN
?BPCP 0
>bgt NoHidden
=n5 LayN
:NoHidden
! Now build output layer
@LLdf !start with default layer again
=LDln "Out" !layer name
=Lpes &Out !Number of PEs
=Lsum "Sum"
=Ltrn "Linear"
=Lcmp "Direct"
=Lerf "standard"
?BPTf "DNNA" !Check for DNNA
>bne DNNA2
=Lsum "DNNA" !DNNA summation
=Ltrn "DNNA" !DNNA transfer
>br LinOut !Don't use Linear Output for DNNA
:DNNA2
! Not DNNA.
=Ltrn "Linear" !Assume linear
?BPSM 0 !Softmax activation?
>bgt SoftMax1 !Linear output for SoftMax
?BPLi 0 !Linear Output?
>bgt LinOut !yep
=Ltrn BPTf !Transfer function
>br LinOut
:SoftMax1
! Force following for SoftMax.
=Lcmp "SoftMax"
=Lerf "SoftMax" !Does out-err instead of trn-err
:LinOut
=Llrn BPLf !Learning Rule
!Use net global schedules for DBD and EDBD. Create
!schedules for others
?BPLf "Delta-Bar-Delta" !DBD?
>beq LRS3 !If yes, use net global
?BPLf "Ext DBD" !EDBD
>beq LRS3 !If yes, use net global
=BBLC OPLC !output learning coef.
@NLRS LDln
#Incl "mapsched.iif" !corrupts n0,n1,f0,f1,f2
=Llrs LDln !Point to it
:LRS3
=f0 n2 !# PEs in previous layer
#Incl "wghtinit.iif"
=LInH f1
=LInL 0.0
-LInL LInH !-ve of high init limit
=n2 Lpes !#processing elements
@LDfW !Default # weight fields
@LAdd
=n7 LayN !current layer index
! Now do connections.
=cnwt 1.0
=cnty WVar !Variable
=cnsc WRel !Relative
! Connect fully with variable weights
! n5 to n6 are source layers (n5=n6 if prior connections have
! not been requested).
=SPEl LayN
@SlPE
:MpLyrs
=NPEl n5
@NrPE
@LCFl !Full Connections
+n5 1
?n5 n6
>ble MpLyrs
! Now the bias
?BPBi 0
>ble NoBias2
=NPEl -1
@NrPE
@LCFl !Full Connections
:NoBias2
! Check-pointing
?BPTf "DNNA"
>bne DNNA3
=DLnN 1 !learn count for Check Points
=MWLF 1 !turn on weight limiting
=WtVl 0.99 !max value for weight limiting
:DNNA3
:NotMap2
=LnPr 0 !no pruning
@LLsl !load super layer
!
! I/O parameters:
!
=Llnn "train" !name of learn input
=Lrcn "test" !name of recall output
#Incl "stdioset.iif" !standard I/O settings
=Lax1 Epch !set epoch from dialog
! Target ranges for MinMax tables
! Set up default settings
=Lscl -1.0 !input low-value
=Loff 1.0 !input high-value
=Llow 0.0 !output low-value
=Lhgh 1.0 !output high-value
?SMmp 0
>beq RngDone
?BPSM 0 !Softmax activation?
>bgt RngDone !if yes,default settings are OK
! Set up defaults for mapping (Unipolar)
=Llow 0.2 !output low-value
=Lhgh 0.8 !output high-value
?BPTf "DNNA" !DNNA?
>beq RngDone !Yes (Linear output not allowed)
! Linear output overrides transfer function
?BPLi 0 !Linear Output?
>bne BiPolar !If yes, bipolar
?BPTf "Sigmoid" !Sigmoid?
>beq RngDone !Yes
?BPTf "Perceptron" !Perceptron?
>beq RngDone !Yes
?BPTf "StepFunction" !Step function?
>beq RngDone !Yes
:BiPolar
=Llow -0.8 !output low-value
:RngDone
! *** Load the Control Strategy and schedules ***
!
=LrnN MpLC !end of Self organizing phase
=Llrs 0
?SMmp 0
>beq LRS4 !Skip schedules if no mapping
=Lctl "sommap" !mapping Control Strategy
=RnLm 0 !learn for
+LrnN 5000 !Go on a bit further than SOM phase
!Use default fixed schedules for DBD and EDBD.
?BPLf "Delta-Bar-Delta" !DBD?
>bne NotDBD2 !Branch to next test if not
=Llrs "somdbd" !Fixed schedule
>br LRS5 !Continue
:NotDBD2
?BPLf "Ext DBD" !EDBD
>bne LRS5 !Branch if not
=Llrs "somedbd" !Fixed schedule
>br LRS5
:LRS4
=Lctl "somnomap" !No mapping Control Strategy
=RnLm 4 !learn until
:LRS5
@SVsl !save it back
!
! Miscellaneous globals
=Grph 1 !Activate instrument list
=jogl -.1 !lower limit for jog
=jogh +.1 !upper limit for jog
=seed 257 !starting seed number
@seed !set the seed
!
! Recall/Test modes
=RnTm 1
=RnRm 1
!
!
! Initialize the network
!
@Nini
@EOF